<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /**
       * @param {character[][]} board
       * @return {boolean}
       */
      var isValidSudoku = function (board) {
        for (var i = 0; i < board.length; i++) {
          // board[i] 拿到每一行
          for (var j = 0; j < board[i].length; j++) {
            if(board[i][j]==='.') continue
            // 遍历每一行有没有相同数字
            for (var k = j + 1; k < board[i].length; k++) {
              if (board[i][j] === board[i][k] && board[i][j] !=='.') {
                return false;
              }
            }
            // 需要遍历每一列对比
            for (var k = i + 1; k < board[i].length; k++) {
              if(board[i][j]===board[k][j] && board[i][j]!=='.'){
                return false
              }
            }
          }
        }
        // 行
        for(var i=0;i<board.length;i++){
          // 列
          for(var j=0;j<board[i].length;j++){
            if(i<3 && j<3 && 1){

            }
          }
        }
        return true;
      };

      var board = [
        ["5", "3", ".", ".", "7", ".", ".", ".", "."],
        ["6", ".", "3", "1", "9", "5", ".", ".", "."],
        [".", "9", "8", ".", ".", ".", ".", "6", "."],
        ["8", ".", ".", ".", "6", ".", ".", ".", "3"],
        ["4", ".", ".", "8", ".", "3", ".", ".", "1"],
        ["7", ".", ".", ".", "2", ".", ".", ".", "6"],
        [".", "6", ".", ".", ".", ".", "2", "8", "."],
        [".", ".", ".", "4", "1", "9", ".", ".", "5"],
        [".", ".", ".", ".", "8", ".", ".", "7", "9"],
      ];
      console.log(isValidSudoku(board));
    </script>
  </body>
</html>
